package mkv.MyGUI;
import processing.core.*;

/**
 * This simple MyGUIObject allows an image to be loaded and positioned within a MyGUIGroup.
 * It takes advantage of the _scale, _rotation and _visible variables as well.
 */

public class MyGUIImage extends MyGUIObject {

  /* Core variables */
  PImage _icon;
  
  /* Constructors */
  public MyGUIImage(PApplet root, int x, int y, PImage icon) {
    super(root, x, y);
    _root = root;
    _icon = icon;
    _width = icon.width;
    _height = icon.height;
  }
     
  public void drawStates() {
    _root.pushMatrix();
    _root.translate(_x, _y);
    _root.scale(_scale);
    _root.rotate(PApplet.radians(_rotation));
    _root.imageMode(PApplet.CORNERS);
    _root.image(_icon, -_width/2, -_height/2, _width/2, _height/2);
    _root.popMatrix();
  }
}
